package com.study.servlet;

import com.study.dao.AwardInfoDAO;
import com.study.dao.impl.AwardInfoDAOImpl;
import com.study.dto.MedalDto;
import com.study.dto.MedalSearchDto;
import com.study.service.MedalSearchService;
import com.study.service.impl.MedalSearchServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @PackgeName: com.study.servlet
 * @ClassName: Country
 * @Author: 严志祥
 * Date: 2022-05-14 12:17
 * project name: web_project_medal
 * @Version:
 * @Description:
 */
@WebServlet("/country.let")
public class CountryServlet extends HttpServlet{
    private AwardInfoDAO dao = new AwardInfoDAOImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try{
            String countryCode = req.getParameter("countryCode");
            List<MedalDto> list = dao.selectAward1(countryCode);
            req.setAttribute("l",list);
            List<MedalDto> list2 = dao.selectAward2(countryCode);
            req.setAttribute("l2",list2);
            List<MedalDto> list3 = dao.selectAward3(countryCode);
            req.setAttribute("l3",list3);
            req.getRequestDispatcher("/country.jsp").forward(req,resp);
        }catch (Exception e){
            throw new ServletException("获取国家奖牌错误", e);
        }
    }
}
